<template>
  <el-form-item label="异步">
    <el-switch v-model="elementAsync" @change="updateElementAsync" />
  </el-form-item>
  <el-form-item label="独占任务">
    <el-switch v-model="elementValidation" @change="updateElementValidation" />
  </el-form-item>
  <el-form-item label="完成异步">
    <el-switch v-model="elementCompleteAsync" @change="updateElementCompleteAsync" />
  </el-form-item>
  <el-form-item label="补偿任务">
    <el-switch v-model="elementCompensation" @change="updateElementCompensation" />
  </el-form-item>
</template>
  
  <script lang="ts">
import { defineComponent } from 'vue';
import { mapState } from 'pinia';
import modelerStore from '@wf/components/bpmnjs/store/modeler';
import { getAsyncValue, setAsyncValue, getCompensationValue, setCompensationValue, getFormFieldValidationValue, setFormFieldValidationValue } from '@wf/components/bpmnjs/bo-utils/assigneeUtil';
import { getCompleteAsyncValue, setCompleteAsyncValue } from '@wf/components/bpmnjs/bo-utils/callActivityUtil';

export default defineComponent({
  name: 'ElementBasicAssignInfo',
  data() {
    return {
      elementAsync: false,
      elementCompensation: false,
      elementValidation: false,
      elementCompleteAsync: false
    };
  },
  computed: {
    ...mapState(modelerStore, ['getActive', 'getActiveId'])
  },
  mounted() {
    this.init();
  },
  methods: {
    init() {
      this.elementAsync = getAsyncValue(this.getActive) || false;
      this.elementCompensation = getCompensationValue(this.getActive) || false;
      this.elementValidation = getFormFieldValidationValue(this.getActive) || false;
      this.elementCompleteAsync = getCompleteAsyncValue(this.getActive) || undefined;
    },
    updateElementAsync(value: string) {
      setAsyncValue(this.getActive, value);
    },
    updateElementValidation(value: string) {
      setFormFieldValidationValue(this.getActive, value);
    },
    updateElementCompensation(value: string) {
      setCompensationValue(this.getActive, value);
    },
    updateElementCompleteAsync(value: string) {
      setCompleteAsyncValue(this.getActive, value);
    }
  }
});
</script>
  